package edu.neu.swc.cloud.service.impl;

import edu.neu.swc.cloud.dao.ProductDao;
import edu.neu.swc.cloud.domain.Product;
import edu.neu.swc.cloud.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("productService")
public class ProductServiceImpl implements ProductService {

    @Autowired
    ProductDao productDao;

    @Override
    public List<Product> findAll() {
        return productDao.findAll();
    }

    @Override
    public void addProduct(Product product) {
        productDao.addProduct(product);
    }

    @Override
    public Product findProById(int pro_id) {
        return productDao.findProById(pro_id);
    }

    @Override
    public void deleteProById(int pro_id) {
        productDao.deleteProductById(pro_id);
    }

    @Override
    public void updatePro(Product product) {
        productDao.updateProduct(product);
    }

    @Override
    public List<Product> findProByPage(int start, int rows, Map<String, String[]> condition) {
        return null;
    }

    @Override
    public int findTotalCount(Map<String, String[]> condition) {
        return 0;
    }

    @Override
    public List<Product> findProByCon(Product product) {
        return productDao.findProByCon(product);
    }

    @Override
    public int getProductCounts(String pro_name) {
        return productDao.getProductCounts(pro_name);
    }

    @Override
    public List<Product> findProductByQuery(String pro_name, int pageStart, int pageSize) {
        return productDao.findProductByQuery(pro_name,pageStart,pageSize);
    }

    @Override
    public Product findProductByCode(String pro_name) {
        return productDao.findProductByName(pro_name);
    }
}
